package lion.test.pathvar;

import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author lion
 * @email hl_0074@sina.com
 * @date 2014年6月12日
 */
public class T {

	public static void main(String[] args) {

		Map<String, String> pathvars = new HashMap<String, String>();
		pathvars.put("admin", "admin111");
		pathvars.put("login", "loginbbb/ccC");
		String src = "cms/#{admin}/#{LOGIN}";
		Pattern p = Pattern.compile("\\#\\{(\\w+)\\}");
		Matcher m = p.matcher(src);
		StringBuffer sbu = new StringBuffer();
		while (m.find()) {

			m.appendReplacement(sbu, pathvars.get(m.group(1).toLowerCase()).toLowerCase());
		}
		m.appendTail(sbu);
		System.out.println(sbu.toString());
	}
}
